using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace G15_Agent.Models.Mapping
{
    public class HoaDonNCCMap : EntityTypeConfiguration<HoaDonNCC>
    {
        public HoaDonNCCMap()
        {
            // Primary Key
            this.HasKey(t => t.MaHoaDon);

            // Properties
            this.Property(t => t.MaHoaDon)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.MaNCC)
                .HasMaxLength(15);

            // Table & Column Mappings
            this.ToTable("HoaDonNCC");
            this.Property(t => t.MaHoaDon).HasColumnName("MaHoaDon");
            this.Property(t => t.MaNCC).HasColumnName("MaNCC");
            this.Property(t => t.NgayLap).HasColumnName("NgayLap");
            this.Property(t => t.DonGia).HasColumnName("DonGia");
            this.Property(t => t.TrangThai).HasColumnName("TrangThai");

            // Relationships
            this.HasOptional(t => t.DanhSachNCC)
                .WithMany(t => t.HoaDonNCCs)
                .HasForeignKey(d => d.MaNCC);

        }
    }
}
